package digui;

import java.util.Scanner;

public class huiwen {
    public static void main(String[] args) {
        Huiwenjudgle huiwenjudgle = new Huiwenjudgle();
        System.out.println("请输出您需要判断的字符:");
        String str = new Scanner(System.in).next();
        System.out.println("你输入的字符为:"+str);
        boolean huiwen = huiwenjudgle.huiwen(str, 0, str.length());
        if(huiwen){
            System.out.println(str+"是回文串");
        }else {
            System.out.println(str+"不是回文串");
        }
    }
}
class Huiwenjudgle{
    public static boolean huiwen(String str,int begin,int end){
        if(begin==str.length()){
            return true;
        }else {
            if(str.charAt(begin)!=str.charAt(end-1)){
                return false;
            }else{
               return huiwen(str,begin+1,end-1);
            }
        }
    }
}
